package org.zpmis.domain.company.vo;

import lombok.Data;
import org.zpmis.domain.company.model.Company;

import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;

@Data
public class GetCompanyDetailVo {
    /**
     * 自增ID
     */
    private Long id;

    /**
     * 企业名称
     */
    private String name;

    /**
     * 联系人
     */
    private String contactPerson;

    /**
     * 联系手机号
     */
    private String contactMobile;

    /**
     * 手机区号
     */
    private String regionCode;

    /**
     * 统一社会信用代码
     */
    private String creditCode;

    /**
     * 法定代表人
     */
    private String legalPerson;

    /**
     * 组织机构代码
     */
    private String orgCode;

    /**
     * 注册地址
     */
    private String registerAddress;

    /**
     * 邮箱
     */
    private String email;

    /**
     * 所属行业
     */
    private String belongIndustry;

    /**
     * 公司类型
     */
    private Integer companyType;

    /**
     * 注册资本
     */
    private String registerCapital;

    /**
     * 经营范围
     */
    private String businessScope;

    /**
     * 开户银行
     */
    private String bankName;

    /**
     * 开户名
     */
    private String bankAccountName;

    /**
     * 开户账号
     */
    private String bankAccount;

    /**
     * 企业用户类型 1意向2个体3代理4内部用户
     */
    private Integer userType;

    /**
     * 状态 0未启用1启用
     */
    private Integer status;

    /**
     * 客户来源 1官网2其他
     */
    private Integer customerSource;

    /**
     * 备注
     */
    private String remark;

    /**
     * 审核状态 0审核中 1通过2未通过
     */
    private Integer auditStatus;

    /**
     * 审核人id
     */
    private Long auditUid;

    /**
     * 审核人
     */
    private String auditPerson;

    /**
     * 审核时间
     */
    private String auditTime;

    /**
     * 附件信息
     */
    private String attachment;

    /**
     * 创建时间
     */
    private String createTime;

    /**
     * 修改时间
     */
    private String updateTime;

    /**
     * 企业code
     */
    private String companyCode;

    /**
     * 所属代理id
     */
    private Long agentId;

    public static GetCompanyDetailVo toCompanyDetailVo(Company company) {
        if(company == null){
            return null;
        }
        GetCompanyDetailVo companyDetailVo = new GetCompanyDetailVo();
        companyDetailVo.setId(company.getId());
        companyDetailVo.setName(company.getName());
        companyDetailVo.setContactPerson(company.getContactPerson());
        companyDetailVo.setContactMobile(company.getContactMobile());
        companyDetailVo.setRegionCode(company.getRegionCode());
        companyDetailVo.setCreditCode(company.getCreditCode());
        companyDetailVo.setLegalPerson(company.getLegalPerson());
        companyDetailVo.setOrgCode(company.getOrgCode());
        companyDetailVo.setRegisterAddress(company.getRegisterAddress());
        companyDetailVo.setEmail(company.getEmail());
        companyDetailVo.setBelongIndustry(company.getBelongIndustry());
        companyDetailVo.setCompanyType(company.getCompanyType());
        companyDetailVo.setRegisterCapital(company.getRegisterCapital());
        companyDetailVo.setBusinessScope(company.getBusinessScope());
        companyDetailVo.setBankName(company.getBankName());
        companyDetailVo.setBankAccountName(company.getBankAccountName());
        companyDetailVo.setBankAccount(company.getBankAccount());
        companyDetailVo.setUserType(company.getUserType());
        companyDetailVo.setStatus(company.getStatus());
        companyDetailVo.setCustomerSource(company.getCustomerSource());
        companyDetailVo.setRemark(company.getRemark());
        companyDetailVo.setAuditStatus(company.getAuditStatus());
        companyDetailVo.setAuditUid(company.getAuditUid());
        companyDetailVo.setAuditPerson(company.getAuditPerson());
        companyDetailVo.setAuditTime(company.getAuditTime() == null ? "" : LocalDateTime.ofInstant(Instant.ofEpochMilli(company.getAuditTime()), ZoneId.systemDefault()).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
        companyDetailVo.setAttachment(company.getAttachment());
        companyDetailVo.setCreateTime( LocalDateTime.ofInstant(Instant.ofEpochMilli(company.getCreateTime()), ZoneId.systemDefault()).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
        companyDetailVo.setUpdateTime( LocalDateTime.ofInstant(Instant.ofEpochMilli(company.getUpdateTime()), ZoneId.systemDefault()).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
        companyDetailVo.setCompanyCode(company.getCompanyCode());
        companyDetailVo.setAgentId(company.getAgentId());
        return companyDetailVo;
    }
}
